<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return=array();
if($_RQ['op']=='get' || $_RQ['op']=='other'){
	$styles=get_plugin_styles();
	$intypes=get_plugin_intypes();
	$nolegao=intval($_RQ['nolegao']);
	$params=array('hide'=>0);
	$return['params']['groupid']=0;
	if($_RQ['keyword']){
		$params['title like']='%'.$_RQ['keyword'].'%';
		$return['params']['keyword']=$_RQ['keyword'];
		unset($styles['1']);
		$groups=$styles;
		foreach($intypes as $k=>&$inv){
				if($k){
					$groups[$k]=$inv;
				}else{
					$groups[18]=$inv;
				}
		}
	}
	if($nolegao){
			if(!$_RQ['keyword']){
				$params['is_legao']=0;
			}
			unset($styles['1']);
			$groups=$styles;
			if($_RQ['groupid']){
				$params['style']=intval($_RQ['groupid']);
				$return['params']['groupid']=intval($_RQ['groupid']);
			}
	}else{
			$params['is_legao']=1;
			if($_RQ['groupid']){
				if($_RQ['groupid']!='18'){
					$params['intype']=intval($_RQ['groupid']);
				}else{
					$params['intype']=0;
				}
				$return['params']['groupid']=intval($_RQ['groupid']);
			}
			
			foreach($intypes as $k=>&$inv){
				if($k){
					$groups[$k]=$inv;
				}else{
					$groups[18]=$inv;
				}
			}
			unset($styles['1'],$styles['2']);
	}
	if(!$_SESSION['isfounder']){
		$pluginids=str_array($_SESSION['user']['plugin_actions']);	
		if($pluginids){
			$params['id']=$pluginids;
		}else{
			$params['id']=0;
		}
	}
	$pindex = max(1, intval($_RQ['page']));
	$psize = 21;
	$total='';
	$orderby='`paixu` desc, `tuijie` desc ,`price` desc, `id` desc';
	$list=pdo_getslice('core_plugins',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($list as $k=>$item){
				
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['groups']=$groups;
	$return['params']['nolegao'] =$nolegao;
	if($nolegao){
		$top_plugin_menu=get_plugin_styles();
		foreach($top_plugin_menu as &$child){
			$child=array('title'=>$child,'child'=>array());
		}
		$top_plugin_menu['7']=array('title'=>'其他应用','child'=>array());
		$plugins=pdo_getall('core_plugins',array('hide'=>0,'is_legao'=>0),array('name','title','style'),'','star desc,paixu desc,id desc');
		foreach($plugins as $row){
			if(!$row['style'] || $row['style']>6){
				$row['style']=7;
			}
			$top_plugin_menu[$row['style']]['child'][]=array('url'=>array('plugin'=>$row['name'],'action'=>'basic.module_home'),'title'=>$row['title']);
		}
		foreach($top_plugin_menu as $key1=>&$menu){
			foreach($menu['child'] as $key2=>&$sub){
				if(is_array($sub['url']) && !check_permission($sub['url']['plugin'],$sub['url']['action'],$sub['url']['op'])){
					unset($menu['child'][$key2]);
					continue;
				}
			}
		}
		$top_plugin_menu=array_values($top_plugin_menu);
		//set_html('top_plugin_menu',$top_plugin_menu);
	}
	$return['payset']=core_setting('pay');
	set_html('title','行业应用');
	exi($return);
}
?>